<template>
	<!--商家我的页面-->
	<view class="content">
		<view class="userback">
			<img src="../../../static/icon/me.png">
			<view class="ad-me-text">
				<view class="userName">商家昵称：{{!merchant.merchantName ?'' : merchant.merchantName}}</view>

			</view>
		</view>
		<!--列表开始-->
		<view class="myList">
			<view class="mineList">
				<navigator url="./mine-business/index">
					<view class="ad-mineList">
						<view class="ad-mineimg">
							<image src="../../../static/icon/scan2.png" ></image>
						</view>
						<view class="ad-mineList-text" space="emsp">商家二维码认证</view>
						<view class="ad-mineList-icon">></view>
					</view>
				</navigator>
			</view>
			<view class="mineList">
				<navigator url="./perferctUser/perfectUser">
					<view class="ad-mineList">
						<view class="ad-mineimg">
							<image src="../../../static/icon/minexx.png" ></image>
						</view>
						<view class="ad-mineList-text" space="emsp">完善商户信息</view>
						<view class="ad-mineList-icon">></view>
					</view>
				</navigator>
			</view>
			<!-- <view class="cu-item">
				<view class="main-img-home">
					<image class="main-img" src="../../../static/icon/gywm.png"></image>
				</view>
				<view class="main-text">
					<text class="main-text-title" space="emsp">关于我们</text>
				</view>
			</view> -->
		</view>
		<!--列表结束-->
		<!--按钮开始-->
		<view class="home-button">
			<button @click="qhuser" class="ad-botton">切换用户</button>
		</view>
		<view class="taBbar">
			<view-tabbar :current="0"></view-tabbar>
		</view>
	</view>
</template>
<script>
	import tabbar from "@/components/tabbar/tabbar1.vue"
	export default {
		data() {
			return {
				merchantInfo: {},
				merchant: {
					merchantName: '',
				}, //商户信息
				
			}
		},
		components: {
			'view-tabbar': tabbar

		},
		onShow() {
			uni.hideTabBar({
				animation: false
			})
		},
		onLoad() {
			var me = this;
			// 商家是否登录
			uni.setStorageSync("ROLE", 2)
			var merchantInfo = uni.getStorageSync("merchantInfo")
			if (!merchantInfo) {
				uni.login({
					provider: "weixin",
					success(wxRes) {
						var code = wxRes.code;
						console.log("code=" + code);
						uni.request({
							url: me.$ServerUrl + '/invoice/api/wx/getMerchantInfo', //8080
							data: {
								"code": code,
							},
							header: {
								'content-type': 'application/x-www-form-urlencoded' // 默认值JSON格式
							},
							method: "GET",
							success: (res) => {
								uni.setStorageSync("merchantInfo",res.data);
								me.merchantInfo = res.data ;
								
							},
						})
					}
				});
			}else{
				me.merchantInfo = merchantInfo ;
				console.log("me.merchantInfo = "+JSON.stringify(me.merchantInfo))
				//根据商家ID查询获取商家信息，赋值商家名称
				uni.request({
					url: me.$ServerUrl + '/invoice/api/merchant/getMerchantById', //根据商家id查询商家详情
					data: {
						id: me.merchantInfo.id
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded' // 默认值JSON格式
					},
					method: "GET",
					success: (res) => {
						console.log("商家详情："+JSON.stringify(res))
						me.merchant.merchantName =res.data.merchantName
						uni.setStorageSync("merchantInfo",res.data)
					},
				})
			}
		},
		methods: {
			qhuser(e) {
				console.log('点击了呀');
				//
				uni.switchTab({
					url: '../../user/home/index',
				})
			}

		}


	}
</script>
<style>
	page{
		width: 100%;
		height: 100%;
		background-color: #e1e5eb;
	}
	.userback {
		height: 150px;
		/* background-image: url('https://bpic.588ku.com//back_origin_min_pic/21/03/15/9e5c39dea7286bcb984e61e640f59baa.jpg!/fw/750/quality/99/unsharp/true/compress/true'); */
		background-repeat: no-repeat;
		background-size: 100%;
		text-align: left;
		background-color: #ffffff;
		display: flex;
		align-items: center;
	
	}
	
	.userback img {
		margin: 10px;
		border-radius: 51px;
		margin-top: 21px;
		width: 80px;
		height: 80px;
	}
	
	.userName {
		color: #111111;
		font-size: 0.9rem;
	}
	.ad-me-text{
		text-align: left;
		margin-left: 10px;
	}
	/* list */
	.myList{
		margin-top: -30px;
	}
	.mineList{
		margin-top: 5px;
		margin-left: 10px;
		margin-right: 10px;
		border: 1px solid #eaeaea;
		background-color: #ffffff;
		border-radius: 10px;
	}
	.ad-mineList{
		display: flex;
		height: 40px;
		align-items: center;
	}
	.ad-mineimg image{
		width: 60upx;
		height: 60upx;
		margin-left: 10px;
		margin-top: 5px;
	}
	.ad-mineList-text{
		width: 150px;
		margin-left: 20px;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}
	.ad-mineList-icon{
		position:absolute;
		right: 0;
		margin-right: 30px;
	}
	.home-button{
		margin: 10px;
	}
	.ad-botton{
		background-color: #505050;
		color: #FFFFFF;
	}
</style>
